package com.heima.admin.controller.v1;

import com.heima.admin.service.AdUserService;
import com.heima.api.admin.LoginControllerApi;
import com.heima.model.admin.dtos.AdUserDto;
import com.heima.model.admin.pojos.AdUser;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/login")
public class LoginController implements LoginControllerApi {

    @Autowired
    AdUserService adUserService;

    /**
     * 登录
     *
     * @param adUserDto
     * @return
     */
    @Override
    @PostMapping("/in")
    public ResponseResult login(@RequestBody @Validated AdUserDto adUserDto) {
        return adUserService.login(adUserDto);
    }

    /**
     * 注册
     *
     * @param adUser
     * @return
     */
    @Override
    @PutMapping("/regist")
    public ResponseResult regist(@RequestBody AdUser adUser) {
        return adUserService.regist(adUser);
    }
}
